package com.barras;

import org.achartengine.ChartFactory;
import org.achartengine.GraphicalView;
import org.achartengine.chart.BarChart.Type;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;

public class Barras extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    
    public void barGraphHandler (View view)
    { 
    	classBarra barra = new classBarra();
    	Intent intentBarras = barra.getIntent(this);
    	//startActivity(intentBarras);
    	GraphicalView mChartview;
		LinearLayout layout = (LinearLayout) findViewById(R.id.Grafica);
		mChartview = ChartFactory.getBarChartView(this, barra.dataset, barra.mRenderer, Type.DEFAULT);
		layout.removeAllViews();
		layout.addView(mChartview, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    }
    
    public void stackedGraphHandler (View view)
    {     	
    	StackedBar barra = new StackedBar();
    	//startActivity(i);
    	GraphicalView mChartview;
		LinearLayout layout = (LinearLayout) findViewById(R.id.Grafica);
		mChartview = (GraphicalView) barra.getView(this);
		layout.removeAllViews();
		layout.addView(mChartview, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    }
    
    public void lineGraphHandler (View view)
    { 
    	classLine line = new classLine();
		Intent lineIntent = line.getIntent(this);
		//startActivity(lineIntent);
		//setContentView(line.getIntent(this));
		GraphicalView mChartView;
		LinearLayout layout = (LinearLayout) findViewById(R.id.Grafica);
	    mChartView = ChartFactory.getLineChartView(this, line.dataset, line.mRender);
	    layout.removeAllViews();
	    layout.addView(mChartView, new LayoutParams(LayoutParams.FILL_PARENT,
		               LayoutParams.FILL_PARENT));
    }
}